package gen.kaynak.navitrack.messageProcessState;

import gen.kaynak.navitrack.messageProcessStrategy.*;

public class SecondIntegerProcessing extends ACMessageProcessState {
	private static SecondIntegerProcessing state = new SecondIntegerProcessing();
	private MessageProcessStrategyManager objCLLP;

	private SecondIntegerProcessing() {

	}

	public static ACMessageProcessState Instance() {
		return state;

	}

	@Override
	void ProcessWhiteSpace(char c, MessageProcessStateManager mpm) {
		mpm.calculateSeconds();
		objCLLP = new MessageProcessStrategyManager(
				new SignExistenceCheckProcessor());
		if (objCLLP.Process(c, mpm)) {
			mpm.calculateCoordinate();
			ChangeState(mpm, CoordinateDiscovered.Instance());
		} else {
			ChangeState(mpm, SecondDiscovered.Instance());
		}

	}

	@Override
	void ProcessLetter(char c, MessageProcessStateManager mpm) {
		mpm.calculateSeconds();
		objCLLP = new MessageProcessStrategyManager(
				new SignExistenceCheckWithLetterProcessor());
		if (objCLLP.Process(c, mpm)) {
			mpm.calculateCoordinate();
			ChangeState(mpm, CoordinateDiscovered.Instance());
		} else {
			ChangeState(mpm, SecondDiscovered.Instance());
		}

	}

	@Override
	void ProcessPunctuation(char c, MessageProcessStateManager mpm) {
		switch (c) {
		case '.':
			mpm.appendSeconds(c);
			ChangeState(mpm, SecondFractionalProcessing.Instance());
		default:
			mpm.calculateSeconds();
			objCLLP = new MessageProcessStrategyManager(
					new SignExistenceCheckProcessor());
			if (objCLLP.Process(c, mpm)) {
				mpm.calculateCoordinate();
				ChangeState(mpm, CoordinateDiscovered.Instance());
			} else {
				ChangeState(mpm, SecondDiscovered.Instance());
			}
		}

	}

	@Override
	void ProcessSymbol(char c, MessageProcessStateManager mpm) {
		mpm.calculateSeconds();
		objCLLP = new MessageProcessStrategyManager(
				new SignExistenceCheckProcessor());
		if (objCLLP.Process(c, mpm)) {
			mpm.calculateCoordinate();
			ChangeState(mpm, CoordinateDiscovered.Instance());
		} else {
			ChangeState(mpm, SecondDiscovered.Instance());
		}

	}

	@Override
	void ProcessNumber(char c, MessageProcessStateManager mpm) {
		mpm.appendSeconds(c);
	}

}
